{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "08823fd9-4d2e-4676-9a06-8b330287b835",
   "metadata": {},
   "source": [
    "Chapter 04\n",
    "# for循环\n",
    "Book_1《编程不难》 | 鸢尾花书：从加减乘除到机器学习  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "b19430df-029c-4de8-a1aa-e5b7d5d81e86",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "P\n",
      "y\n",
      "t\n",
      "h\n",
      "o\n",
      "n\n",
      " \n",
      "i\n",
      "s\n",
      " \n",
      "F\n",
      "U\n",
      "N\n",
      "!\n"
     ]
    }
   ],
   "source": [
    "x_string = 'Python is FUN!'\n",
    "\n",
    "# 利用for循环打印每个字符\n",
    "for i_str in x_string:\n",
    "    print(i_str)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "797c5495",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'P'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x_string[0]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "0426ea5b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'y'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x_string[1]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "66668e74",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'yt'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x_string[1:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "c70a62ee",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\u001b[1;31mSignature:\u001b[0m  \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0msep\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m' '\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mend\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'\\n'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfile\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mflush\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mFalse\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mDocstring:\u001b[0m\n",
      "Prints the values to a stream, or to sys.stdout by default.\n",
      "\n",
      "sep\n",
      "  string inserted between values, default a space.\n",
      "end\n",
      "  string appended after the last value, default a newline.\n",
      "file\n",
      "  a file-like object (stream); defaults to the current sys.stdout.\n",
      "flush\n",
      "  whether to forcibly flush the stream.\n",
      "\u001b[1;31mType:\u001b[0m      builtin_function_or_method"
     ]
    }
   ],
   "source": [
    "? print"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
